package com.sskj.gocoin.p.activity;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.HttpData;
import com.sskj.gocoin.m.http.JsonCallBack;
import com.sskj.gocoin.p.base.BasePresenter;
import com.sskj.gocoin.v.activity.WebActivity;

import java.util.List;

public class WebActivityPresenter extends BasePresenter<WebActivity> {

    public void gameKepugot() {
        OkGo.<HttpData<List<Object>>>get(HttpConfig.BASE_URL + HttpConfig.GAME_KEPUGOT)
                .execute(new JsonCallBack<HttpData<List<Object>>>(this) {
                    @Override
                    public void _onSuccess(Response<HttpData<List<Object>>> response) {
                        HttpData<List<Object>> body = response.body();
                        if (body.getCode() == 200) {
                            mView.updateUi(body.getMsg());
                        } else {
                            mView.error(body.getMsg());
                        }
                    }

                    @Override
                    public void onError(Response<HttpData<List<Object>>> response) {
                        super.onError(response);
                        HttpData<List<Object>> body = response.body();
                        if (body != null) {
                            mView.error(body.getMsg());
                        }
                    }
                });
    }
}
